package org.libarae.server;

import org.libarae.communication.common.User;


/**
 * @author Tyler Holzer
 *
 * ActiveUser.java -- A part of Libarae
 * Stores a user object, the time of the last activity, and the authkey for that user
 */
public class ActiveUser {
	
	/**
	 * stores the last time user made a request
	 */
	private long timestamp;
	/**
	 * Stores the logged in user
	 */
	private User user; 
	/**
	 * Stores the auth key for the logged in user
	 */
	private String authKey;
	
	/**
	 * Constructor for ActiveUser
	 * 
	 * @param user the user you want to set
	 * @param authKey the authkey for the user
	 */
	public ActiveUser(User user, String authKey) {
		timestamp=System.currentTimeMillis();
		this.user=user;
		this.authKey=authKey;
	}
	
	/**
	 * Returns the time of the last activity
	 * 
	 * @return long 
	 */
	public long getTimestamp() {
		return timestamp;
	}
	
	
	/**
	 * Updates the last activity to now
	 */
	public void nowActive() {
		timestamp=System.currentTimeMillis();
	}
	
	/**
	 * returns the user logged in user 
	 * 
	 * @return User
	 */
	public User getUser() {
		return user;
	}
	
	/**
	 * Returns the AuthKey for the logged in User
	 * 
	 * @return String
	 */
	public String getAuthKey() {
		return authKey;
	}
}
